Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adapt tests to latest changes in ckanext-harvest #263

Merged
merged 1 commit into from
Feb 27, 2024

Conversation

seitenbau-govdata
Copy link
Member

@seitenbau-govdata seitenbau-govdata commented Jan 23, 2024

The workflow tests are currently broken when run with the master version of ckanext-harvest. With this commit in ckanext-harvest the way of initializing the db has been changed.

This PR updates the tests for ckanext-dcat to solve the issue.
But I`m not quite sure if this is an ideal solution. Could someone take a closer look at this?

# TODO move to ckanext-harvest
@pytest.fixture
def harvest_setup():
harvest_model.setup()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps is best to keep the concerns for the clean_db and harvest_setup fixtures separated and keep harvest_setup but refactoring it to use migrate_db_for('harvest') rather than harvest_model.setup()?

Copy link
Member Author

@seitenbau-govdata seitenbau-govdata Feb 7, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could not solve the problem otherwise. Using migrate_db_for('harvest') in harvest_setup or redefining clean_db in the harvester-specific tests (test_harvester.py & test_json_harvester.py) does not seem to solve the issue.
All Tests that include clean_db still throw the following exception:

sqlalchemy.exc.ProgrammingError: (psycopg2.errors.UndefinedTable) relation "harvest_object_extra" does not exist
...
/srv/app/src/ckan/ckan/tests/helpers.py:83: in reset_db
model.repo.rebuild_db()
/srv/app/src/ckan/ckan/model/init.py:229: in rebuild_db
self.delete_all()
/srv/app/src/ckan/ckan/model/init.py:250: in delete_all
connection.execute('delete from "%s"' % table.name)
/usr/lib/python3.8/site-packages/sqlalchemy/engine/base.py:982: in execute
return self.execute_text(object, multiparams, params)
/usr/lib/python3.8/site-packages/sqlalchemy/engine/base.py:1149: in _execute_text
ret = self._execute_context(
/usr/lib/python3.8/site-packages/sqlalchemy/engine/base.py:1247: in _execute_context
self._handle_dbapi_exception(
/usr/lib/python3.8/site-packages/sqlalchemy/engine/base.py:1466: in _handle_dbapi_exception
util.raise_from_cause(sqlalchemy_exception, exc_info)
/usr/lib/python3.8/site-packages/sqlalchemy/util/compat.py:399: in raise_from_cause
reraise(type(exception), exception, tb=exc_tb, cause=cause)
/usr/lib/python3.8/site-packages/sqlalchemy/util/compat.py:153: in reraise
raise value.with_traceback(tb)
/usr/lib/python3.8/site-packages/sqlalchemy/engine/base.py:1243: in _execute_context

Any ideas on how to initialize/create the plugin db tables or to put the right scope for harvest_setup ?

Maybe this was also mentioned in this discussion

@seitenbau-govdata
Copy link
Member Author

@amercader We would like to get the tests working again. Perhaps you'll find some time to have a quick look at this and let us know what do you think about our last investigations? Otherwise, we suggest merging the currently working solution to move forward.

@amercader
Copy link
Member

My apologies @seitenbau-govdata, reading the linked discussion this makes perfect sense.

@amercader amercader merged commit f147f21 into ckan:master Feb 27, 2024
3 checks passed
@seitenbau-govdata seitenbau-govdata deleted the fix-tests branch February 27, 2024 13:58
@seitenbau-govdata
Copy link
Member Author

@amercader No problem. Don't worry. Thanks! 😃

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants